// Account.java
// Represents a customers bank account


public class Account {
	private int accountNumber; // account number
	private double availableBalance; // funds available for withdrawal
	private double totalBalance; // funds available + pending deposits
	public double interestBalance; // interestBalance for x years
	private int years = 3; // Time period of interest rate
	private double interestRate; // Interest rate over time
	public String accountType; // Account type ex. "overdraft"

	// Account constructor initializes attributes
	public Account(int theAccountNumber, double theAvailableBalance,
			double theTotalBalance, String theAccountType) {
		accountNumber = theAccountNumber;
		availableBalance = theAvailableBalance;
		totalBalance = theTotalBalance;
		accountType = theAccountType;
	} // end Account constructor

	// method that can calculate interestRates for the different accountTypes.
	public void updateInterestRate(int years) {
		if (accountType.equals("Overdraft")) {
			interestRate = 0.1;
			interestBalance = totalBalance * Math.pow(1 + interestRate, years);
		}
		if (accountType.equals("Savings")) {
			interestRate = 0.03;
			interestBalance = totalBalance * Math.pow(1 + interestRate, years);
		}
		if (accountType.equals("Budget")) {
			interestRate = 0.01;
			interestBalance = totalBalance * Math.pow(1 + interestRate, years);
		}
	}// end method updateInterestRate

	// returns the accountType
	public String getAccountType() {
		return accountType;
	} // end method getAccountType

	// returns years
	public int getYears() {
		return years;
	} // end method getYears

	// returns available balance
	public double getAvailableBalance() {
		return availableBalance;
	} // end getAvailableBalance

	// returns the total balance
	public double getTotalBalance() {
		return totalBalance;
	} // end method getTotalBalance

	// returns interestBalance
	public double getInterestBalance() {
		return interestBalance;
	} // end method getInterestBalance

	// credits an amount to the account
	public void credit(double amount) {
		totalBalance += amount; // add to total balance
	} // end method credit

	// debits an amount from the account
	public void debit(double amount) {
		availableBalance -= amount; // subtract from available balance
		totalBalance -= amount; // subtract from total balance
	} // end method debit

	// returns account number
	public int getAccountNumber() {
		return accountNumber;
	} // end method getAccountNumber
} // end class Account

/**************************************************************************
 * (C) Copyright 1992-2012 by Deitel & Associates, Inc. and * Pearson Education,
 * Inc. All Rights Reserved. * * DISCLAIMER: The authors and publisher of this
 * book have used their * best efforts in preparing the book. These efforts
 * include the * development, research, and testing of the theories and programs
 * * to determine their effectiveness. The authors and publisher make * no
 * warranty of any kind, expressed or implied, with regard to these * programs
 * or to the documentation contained in these books. The authors * and publisher
 * shall not be liable in any event for incidental or * consequential damages in
 * connection with, or arising out of, the * furnishing, performance, or use of
 * these programs. *
 *************************************************************************/
